package com.bd.scm.module.log.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.scm.dao.mapper.log.BdSysLogMapper;
import com.bd.scm.domain.dto.login.SysLog;
import com.bd.scm.domain.dto.login.SysLogDto;
import com.bd.scm.domain.dto.login.SysLogExport;
import com.bd.scm.module.log.service.BdSysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/** 舍弗勒访客系统日志实现类
 * @author YH
 * @version 1.0
 * @date 2020/12/15 17:47
 */
@Service
public class BdSysLogServiceImp implements BdSysLogService {

    /**
     * 舍弗勒访客系统日志Mapper
     */
    @Autowired
    private BdSysLogMapper bdSysLogMapper;

    /**
     * 插入日志
     * @param sysLogDto 信息
     */
    @Override
    @Transactional
    public void insertBdSysLog(SysLogDto sysLogDto) {
        this.bdSysLogMapper.insertBdSysLog(sysLogDto);
    }

    /**
     * 查询日志
     * @param page
     * @param sysLog
     * @return
     */
    @Override
    public IPage<SysLogDto> getBdSysLogList(Page<SysLogDto> page, SysLog sysLog) {
        OrderItem orderItem = OrderItem.desc("createDate");
        List<OrderItem> orderItemList = new ArrayList<>();
        orderItemList.add(orderItem);
        page.setOrders(orderItemList);
        return this.bdSysLogMapper.getBdSysLogList(page,sysLog);
    }

    /**
     * 导出日志
     * @param sysLog
     * @return
     */
    @Override
    public List<SysLogExport> exportBdSysLogList(SysLog sysLog) {
        return this.bdSysLogMapper.exportBdSysLogList(sysLog);
    }

    /**
     * 获取操作类型
     * @return
     */
    @Override
    public List<JSONObject> getOperationList() {
        return this.bdSysLogMapper.getOperationList();
    }
}
